#include "front/text_normalize.h"

using namespace std;
using namespace ppspeech;

const wregex mcWregexDashLetter(L"([a-zA-Z]+(\\d+)?-)+(\\d+)");

void TextNormalizer::TnReDashLetter(wstring* fpInWsentence, const LanguageEnum fcInLanguage)
{
	wsmatch tWsmatch;

	while(regex_search(*fpInWsentence, tWsmatch, mcWregexDashLetter))
	{
		string tInSentence = wstring2utf8string(*fpInWsentence);
		string tStrReplace = "";
		string tStrDash = wstring2utf8string(tWsmatch[0]);	//匹配到横杆的字符串
		vector<string> tItemDash = StrSplit(tStrDash, "-");	//按横杆分开

		for(size_t i=0; i<tItemDash.size(); i++) {
			const string tcItem = tItemDash[i];

			if( IsStrAllNumber(tcItem) ) {
				//tStrReplace += ReplaceMethod(vector<string>{tcItem}, (fcInLanguage==LANG_EN)?RME_en_negative_decimal:RME_zh_negative_decimal);
				tStrReplace += ReplaceMethod(vector<string>{tcItem}, (fcInLanguage==LANG_EN)?RME_en_telephone:RME_zh_digit_yi1);
			}
			else {
				tStrReplace += tcItem;
			}
			tStrReplace += " ";
		}

		WstrReplacePosition(fpInWsentence, tWsmatch.position(0), tWsmatch.length(0), utf8string2wstring(tStrReplace));
	}
}
